package main;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class Writer {

	private FileWriter arq;
	private PrintWriter writerFile;

	public Writer(String fileName)
	{
		try {
			this.arq = new FileWriter(fileName);
		} catch (IOException e) {
			System.out.println("Nao foi possivel abrir o arquivo");
			e.printStackTrace();
		}
		writerFile = new PrintWriter(arq);
		
	}
	
	public void close()
	{
		try {
			this.arq.close();
		} catch (IOException e) {
			System.out.println("Erro ao fechar o arquivo");
			e.printStackTrace();
		}
	}
	
	public void Write(String... text)
	{
		String textResult = "";
		for(int i=0;i<text.length;i++)
		{
			textResult += text[i] + ",";
		}
		
		textResult = textResult.endsWith(",") ? textResult.substring(0, textResult.length() - 2):textResult;
		this.writerFile.println(textResult);
	}
	
	
}
